#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n;
	string str;
	cin >> n >> str;

	long long s = 0, h = 0, y = 0;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == 's')
			s++;
		else if (str[i] == 'h')
			h += s;
		else if (str[i] == y)
			y += h;
	}

	cout << y << endl;

	return 0;
}